# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Roman Kyrylych <roman@archlinux.org>
# Contributor: Tor Krill <tor@krill.nu>

pkgname=filemanager-actions
pkgver=3.4
pkgrel=6
pkgdesc="File-manager extension which offers user configurable context menu actions"
arch=('loong64' 'x86_64')
url="https://gitlab.gnome.org/GNOME/filemanager-actions"
license=('GPL')
depends=('gtk3' 'libgtop')
makedepends=('intltool' 'caja' 'libnautilus-extension' 'nemo' 'yelp-tools' 'gtk-doc')
optdepends=('caja: supported file manager'
            'nautilus: supported file manager'
            'nemo: supported file manager')
replaces=('caja-actions' 'caja-actions-gtk3' 'nautilus-actions')
source=(https://download.gnome.org/sources/$pkgname/$pkgver/$pkgname-$pkgver.tar.xz
        yelp-tools.patch
        filemanager-actions.appdata.xml)
sha256sums=('10189781af90df4c99fde0fe98eacd2e12f4577eff5dc9b769618d980668a997'
            '4dbe842a20739c05a2d8c62ab7691cfc47669d6a032ad04381624650691d7e6d'
            'b8f9057e535631d6164581763e49c2e480c02a9f75757528f2df26aa182d4670')

prepare() {
  cd $pkgname-$pkgver
  # Fix icon name
  sed -i 's/Icon=fma-config-tool/Icon=filemanager-actions/' src/ui/fma-config-tool.desktop.in
  
  # Don't use deprecated gnome-doc-utils
  sed -i 's/ghelp:filemanager-actions-config-tool/help:fma-config-tool/' src/ui/fma-menu.c
  sed -i 's/ghelp:/help:/g' docs/manual/*/*.{xml,po}
  mv docs/manual/C/{fma-config-tool.xml,index.docbook}
  patch -Np1 -i ../yelp-tools.patch
  autoreconf -fi
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=/usr/lib
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package(){
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 "$srcdir/$pkgname.appdata.xml" "$pkgdir/usr/share/metainfo/$pkgname.appdata.xml"
}
